//
//  PhotoDetailViewController.m
//  paparazzi
//
//  Created by Paul on 10-03-23.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "PhotoDetailViewController.h"


@implementation PhotoDetailViewController

@synthesize selectedPhoto;
@synthesize selectedTitle;
@synthesize scrollView;
@synthesize myImageView;

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
	
    return YES;
}

- (void)viewDidLoad {

	self.title = selectedTitle;	
	
	// add the selected image to the UIImageView
	UIImageView *image = [[UIImageView alloc] initWithImage:selectedPhoto];
	[self setMyImageView:image];
	[image release];
	
	// configure the scrollView and set zoom scale - also implement viewForZoomingInScrollView method see below
	scrollView.contentSize = CGSizeMake(myImageView.frame.size.width, myImageView.frame.size.height);
	scrollView.maximumZoomScale = 5.0;
	scrollView.minimumZoomScale = 0.5;
	
	// start the zoomscale at 1.5 so the image covers the full screen to start out
	scrollView.zoomScale = 1.5;
	
	// add the imageview to the scroll view
	[scrollView addSubview:myImageView];
}

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollview {
	
	return myImageView;
}

- (void)viewWillDisappear:(BOOL)animated {
	
	// before the view disappears, set the status bar style back to default
	[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
	self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
	
}

- (void)viewWillAppear:(BOOL)animated {
	
	// make the status bar translucent to see more of the screen full of information.
	[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackTranslucent;
	self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
	
}

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;

}

- (void)dealloc {
	[selectedPhoto release];
	[selectedTitle release];
	[myImageView release];
    [super dealloc];
}


@end
